import gugga.layout.LayoutGenerator;
import gugga.navigation.INavigationItem;
import gugga.navigation.MenuItemsController;
import gugga.utils.DebugUtils;

/**
 * @author bony
 * NavigationGenerator extends the class LayoutGenerator and overwrite the method handleItemGenerationFinished
 * to register the sub items in the navigation.
 */
class externalContent.NavigationGenerator extends LayoutGenerator 
{ 
	public function handleItemGenerationFinished(aItem:MovieClip, aSubItems:Array, aParentItem:MovieClip,
 		aItemData:Object, aItemNestingDepth:Number, aIsFinal:Boolean)
 	{
 		super.handleItemGenerationFinished(aItem, aSubItems, aParentItem, aItemData, aItemNestingDepth, aIsFinal);
 		
 		if(aIsFinal)
 		{
 			// This application has only primary navigation. 
 			// "parentMenuItem" is the MainNavigation.
 			var parentMenuItem : MenuItemsController = MenuItemsController(aParentItem);
 			
 			for (var i : Number = 0; i < aSubItems.length; i++)
 			{ 				
 				var item : INavigationItem = INavigationItem(aSubItems[i]);
 				var itemID : String = item["ID"];
 				
 				parentMenuItem.registerSubItem(item, itemID, itemID, null, null);
 			}
 		}
 	}	

}